package com.kgc.controller;

import com.kgc.entity.TbItem;
import com.kgc.service.ItemService;
import com.kgc.utils.ItripResult;
import com.kgc.utils.ResultTable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("item")
public class ItemController {

    @Autowired
    private ItemService itemService;
    @RequestMapping("list")
    @ResponseBody
    public ResultTable list(
            @RequestParam(value = "page",defaultValue = "1",required = false) int page,
            @RequestParam(value = "limit",defaultValue = "10",required = false)int limit,
            Long cid){

        return itemService.findAll(page,limit,cid);
        //return itemService.findAll();
    }
    @RequestMapping("add")
    @ResponseBody
    public ItripResult addItem(TbItem item,String content1){
        itemService.addItem(item,content1);
        return ItripResult.ok();//200 ok
    }


}
